Plot
A Swiss knife for displaying 2D data
Plot[expr_, {variable, min, max, step}, opts__]
has HoldFirst attribute. See the list of supported options (opts) down below
Optionsβ
PlotStyleβ
Works as in Mathematica, i.e. per element in expr array, supports color, opacity and etc
Plot[Table[x^y, {y, 6}]//Evaluate, {x, 0,1}, PlotStyle->Table[Blend[{Red, Blue}, i/6], {i, 6}]]
AxesLabelβ
Place labels on your axes
Plot[Sinc[x], {x, 0, 10}, AxesLabel -> {"x", "Sinc[x]"}]
Labels accepts only strings or numbers unlike Mathematica, where you can put everything.
Since it is translated into Text, one can use sort of TeX math input
Plot[PDF[NormalDistribution[0, 1], x], {x, -10, 10}, AxesLabel -> {"wavenumber (cm^{-1})", "absorption \\alpha"}, PlotRange->Full]
It also supports absolute positioning using offset
Plot[PDF[NormalDistribution[0, 1], x], {x, -10, 10}, AxesLabel -> {"wavenumber (cm^{-1})", {"absorption \\alpha", {112,0}}}, PlotRange->Full]
Ticksβ
Customize ticks by providing an array of numbers for both axes
Plot[x, {x, 0, 1}, Ticks->{{0, 0.5, 1}, {}}]
Or by providing as pairs {Number, String} one can specify the displayed text
Plot[x, {x, 0, 1}, Ticks->{{{0, "Zero"}, {0.5, "Half"}, {1,"One"}}, {}}]
Controls πβ
This is more an option for Graphics, but with a bit of a hacking it can be used here as well. The features allows to pan and zoom your plots, that was never possible in Mathematica
Plot[Sin[1/x], {x, 0.001, 0.1}, MaxRecursion->1];
Insert[%, Controls->True, {2,-1}]
Try to use your mouse here
Frameβ
Turns plot into the journals-like styled graph. In general it has much more options to customize the look
Plot[x, {x, 0, 1}, Frame->True]
FrameTicksβ
The same as Ticks, but for this regime.
FrameLabelβ
The same as AxesLabel
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{
"x-axis",
"y-axis"
}]
one can specify an absolute offset for a label by wrapping it into a list
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{
"x-axis",
{"y-axis", {0,50}}
}]
FrameStyleβ
Affects the style of FrameLabels. Use Directive for changing the style
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{"x-axis", "y-axis"}, FrameStyle->Directive[FontSize->16]]
FrameTicksStyleβ
Affects the style of FrameTicks
Plot[x, {x, 0, 1}, Frame->True, FrameLabel->{"x-axis", "y-axis"}, FrameTicksStyle->Directive[FontSize->16]]
TickLabelsβ
Since Plot options are hardcoded in WL core, we cannot add new options, however using trick with Insert any values can be provided to the resulting Graphics expression
To remove unnecessary ticks, use
Plot[x, {x, 0, 1}, Frame->True];
Insert[%, "TickLabels"->{{True, False}, {True, False}}, {2,-1}]
ClippingStyleβ
Show the clipped regions like the rest of the curve and colored
Plot[Sin[x]/x^2, {x, -10, 10}, ClippingStyle -> Red]
Fillingβ
Fill the area under, over of between curves
Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10}, Filling -> Axis]
Possible options will be
BottomTop{1 -> {2}}from curve 1 to 2
Baselineβ
Align graphs by theΒ Β axis in each plot:
{Plot[Im[Zeta[1/2 + I t]], {t, -20, 20}, BaselinePosition -> Axis],
Plot[Re[Zeta[1/2 + I t]], {t, -20, 20}, BaselinePosition -> Axis]} // Row
Epilogβ
Puts any graphics object on top of the data plotted
Plot[Sin[x], {x, 0, 2 Pi}, Epilog -> {PointSize[0.04], Point[{0, 0}], Point[{Pi, 0}], Point[{2 Pi, 0}]}]
It opens up many possibilities, since it provides low-level access to the Graphics canvas.
Prologβ
The same as Epilog, but acts before plotting the data.
ExclusionsStyleβ
Use red lines to indicate the vertical asymptotes
Plot[Tan[x], {x, 0, 10}, Exclusions -> {Cos[x] == 0},
ExclusionsStyle -> Red]
ImageSizeβ
A common option for any graphics
ImageSize -> Width
or
ImageSize -> {Width, Height}
It uses pixels as units
MaxReqursionβ
Affects the accuracy of the plot when it comes to the sudden changes of a sampled function
Plot[Sin[1/x], {x, 0.001, 0.1}, MaxRecursion->1]
The lowest values is 0
Meshβ
Shows sampling points
Plot[Sin[1/x], {x, 0.001, 0.1}, Mesh -> All]
PeformanceGoalβ
Affects the number of sampling points to reduce the load
"Speed""Quality"
PlotPointsβ
Change the initial sampling points
- a number
PlotLegendsβ
Accepts Automatic, "Expressions" or List of expressions to show or explicit legend function, i.e. SwatchLegend, LineLegend or PointLegend
Plot[{Sin[x], Cos[x]}, {x, 0, 5},
PlotLegends -> {"Sin", "Cos"}]
Plot[{Sin[x], Cos[x]}, {x, 0, 5},
PlotLegends -> {Sin, Cos}]
Plot[{Sin[x], Cos[x]}, {x, 0, 5},
PlotLegends -> SwatchLegend["Expressions"]]
Plot[{Sin[x], Cos[x]}, {x, 0, 5},
PlotLegends -> SwatchLegend[Automatic, {Sin, Cos}]]
or
Legend placementβ
Use Placed to adjust the position of your legend, i.e.
Plot[
{x,x^2}, {x,0,1},
PlotLegends->Placed[SwatchLegend[Automatic], {0.2,0.2}]
]
PlotRangeβ
Change the lot range to show the whole area
Plot[Sqrt[x], {x, -5, 5}, PlotRange -> Full]
Or a custom range
Plot[Sqrt[x], {x, -5, 5}, PlotRange -> {{-5,5}, {0,1}}]
RegionFunctionβ
Show the specific area only
Plot[Sin[x], {x, 0, 8 Pi}, RegionFunction -> Function[{x, y}, Abs[y] > 0.5]]
Axesβ
Show or hide axes of the plot
Plot[Sinc[x], {x, 0, 10}, Axes -> False]
Dynamicsβ
Consider to use ManipulatePlot for manipulating parameters of a function in real time